#创建数据库
create schema `bookmgr` ;
go;
use `bookmgr` ;
#创建用户关系表
create table `bookmgr`.`user_info` (
  `userid` int not null auto_increment,
  `username` varchar(45) not null,
  `account` varchar(45) not null,
  `password` varchar(100) not null,
  primary key (`uid`),
  unique index `account_unique` (`account` asc)
);
go;
use `bookmgr` ;
#创建图书关系表
create table `bookmgr`.`book_info` (
  `bookid` int not null,
  `bookname` varchar(45) not null,
  `bookprice` decimal null,
  primary key (`bookid`)
);
go;
use `bookmgr` ;
#创建借书关系表
create table `bookmgr`.`borrow_info` (
  `borrowid` int not null,
  `userid` int null,
  `bookid` int null,
  `qty` int null default 1,
  primary key (`borrowid`),
  foreign key (`userid`)  references `bookmgr`.`user_info` (`userid`),
  foreign key (`bookid`)  references `bookmgr`.`book_info` (`bookid`)
);

